﻿#include "InstructionTurnTableStop.h"

#include "ScriptRunner.h"
#include "TurnTableCodec.h"
#include "StateChecker.h"
#include "Device.h"

__SCRIPTINSTRUCTION_REGISTER(InstructionInstructionTurnTableStopWait,ScriptInstruction::Instruction_TurnTable_Stop,&InstructionTurnTableStop::fromByteArray1);

InstructionTurnTableStop::InstructionTurnTableStop()
{
  instructionFlag = Instruction_TurnTable_Stop;
}

InstructionTurnTableStop::InstructionTurnTableStop(InstructionTurnTableStop const & instructionTurnTableStop)
{
  *this=instructionTurnTableStop;
}

InstructionTurnTableStop& InstructionTurnTableStop::operator=(InstructionTurnTableStop const& instructionTurnTableStop)
{
  *(ScriptInstruction*)this=instructionTurnTableStop;
  return *this;
}

InstructionTurnTableStop::~InstructionTurnTableStop()
{}

void InstructionTurnTableStop::run()
{
  scriptRunner->sendInstruction(deviceId,TurnTableCodec::TurnTable_Stop);
  StateChecker<bool>::next_ifConditionReached(&Device::getTurnTable_runningState_running,
                                              false,
                                              deviceId,
                                              scriptRunner);
}

QString InstructionTurnTableStop::toString()
{
  return QStringLiteral("转台停止");
}

QByteArray InstructionTurnTableStop::toByteArray()
{
  return ScriptInstruction::toByteArray();
}

ScriptInstruction* InstructionTurnTableStop::fromByteArray1(char * const src, int size, int *offset)
{
  (void)src;
  (void)size;
  (void)offset;
  return new InstructionTurnTableStop();
}

